home *** CD-ROM | disk | FTP | other *** search
- :
- # @(#) xsconfig.sh 1.7 91/11/27
- #
- # Copyright (C) 1983-1991 The Santa Cruz Operation, Inc.
- #
- # The information in this file is provided for the exclusive use of the
- # licensees of The Santa Cruz Operation, Inc. Such users have the right
- # to use, modify, and incorporate this code into other products for purposes
- # authorized by the license agreement provided they include this notice
- # and the associated copyright notice with any such product. The
- # information in this file is provided "AS IS" without warranty.
- #
- #
- # Purpose:
- # xsconfig.sh will use X11 and system keyboard configuration files
- # to create the server configuration file
- # '/usr/lib/X11/.Xsco.cfg'.
- #
- # Usage:
- # xsconfig.sh [/usr/lib/X11/csxmaps/csxmap_file /usr/lib/keyboard/keyboard_name]
- #
- # If the optional paramaters (csxmap and keyboard_name) are given
- # this script will call 'mapkey -c' with those paramaters, and then
- # tweak the output file to remove the '[modifiers]' section.
- # The resulting file will be called mapkey.kbd, and it will remain
- # in the current directory. Then, xsconfig will be called with the
- # mapkey.kbd and mod.intl.kbd files, and Mode_switch will be defined to
- # be Mod3.
- #
- # If there are no optional paramaters, xsconfig will be called with
- # default.kbd and mod.usa.kbd files, and Mode_switch will not be defined.
- #
- #
- # Define return values, variables, defaults
- : ${OK=0} ${FAIL=1} ${STOP=10} ${HALT=11}
- tmp=/tmp/xs$$
-
- # Define traps for critical and non critical code.
- trap 'echo "\nInterrupted! Exiting ..."; cleanup $FAIL' 1 2 3 15
-
- # if stoped, try to mop up.
- cleanup() {
- trap '' 1 2 3 15
- [ "$tmp" ] && rm -f $tmp*
- exit $1
- }
- Usage() {
- echo "Usage:"
- echo "xsconfig.sh [/usr/lib/X11/csxmaps/csxmap_file /usr/lib/keyboard/keyboard_name]"
- exit $FAIL
- }
- NoFile() {
- echo "$prog: Error, cannot open file <$1>"
- Usage
- }
-
- # edit the input file to delete the '[modifiers]' section.
- remove_modifiers()
- {
- awk 'BEGIN { in_modifiers= 0; }
- /^\[modifiers\]/ { in_modifiers++; continue; }
- /^\[/ { in_modifiers= 0; }
- { if (in_modifiers) continue;
- else print $0 }
- ' $1 > $2
- return $?
- }
-
- #
- # main()
- #
- prog=$0
- cd /usr/lib/X11/xsconfig
-
- KBD_FILE=default.kbd # setup the defaults for USA
- MOD_FILE=mod.usa.kbd
-
- # see if we are setting up an International keyboard configuration
- [ $# -gt 0 ] && {
- CSXMAP=$1 ; [ -z "$CSXMAP" ] && Usage
- KEYBOARD=$2; [ -z "$KEYBOARD" ] && Usage
- # make sure the files exist.
- [ -f "$CSXMAP" ] || NoFile $CSXMAP
- [ -f "$KEYBOARD" ] || NoFile $KEYBOARD
-
- # run 'mapkey -c' to generate the mapkey.kbd file.
- mapkey -c $CSXMAP $KEYBOARD > $tmp
-
- # don't forget to strip out the modifiers section
- remove_modifiers $tmp mapkey.kbd
-
- # and one more thing, change the Alt_R to Mode_switch
- mv mapkey.kbd $tmp
- sed -e "s/XK_Alt_R/XK_Mode_switch/g" $tmp > mapkey.kbd
-
- # use the new file we created, and the intl modifier file
- KBD_FILE=mapkey.kbd
- MOD_FILE=mod.intl.kbd
- }
-
- # just do it.
- /usr/bin/X11/xsconfig -o /usr/lib/X11/.Xsco.cfg config.txt \
- trans101.kbd $KBD_FILE misc.kbd $MOD_FILE || cleanup $FAIL
-
- cleanup $OK
-